package io.yunjiao.apijson.example;

import io.yunjiao.apijson.example.fastjson2.CustomFastjson2Creator;
import io.yunjiao.apijson.fastjson2.Fastjson2Creator;
import io.yunjiao.apijson.spring.boot.autoconfigure.ApijsonSqlProperties;
import io.yunjiao.apijson.spring.boot.autoconfigure.condition.ApllicationCondition;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 通用配置
 *
 * @author yangyunjiao
 */
@Slf4j
@Conditional(ApllicationCondition.OnFastjson2.class)
@Configuration
public class ExampleSeedAutoConfiguration {
    @PostConstruct
    public void postConstruct() {
        log.info("Example Fastjson2 Auto Configuration");
    }

    @Bean
    public Fastjson2Creator customFastjson2Creator(DataSource dataSource,
                                                   ApijsonSqlProperties sqlProperties) {
        log.debug("Configure Bean [Custom Fastjson2 Creator]");
        return new CustomFastjson2Creator(dataSource, sqlProperties);
    }


}
